<!DOCTYPE html>
<html xmlns=http://www.w3.org/1999/xhtml xmlns:bd=http://www.baidu.com/2010/xbdml>
<head>
    <meta charset="utf-8">
    <title>公告列表</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="format-detection" content="telephone=no">
    <link rel="stylesheet" href="/staff/layui/css/layui.css" media="all" />
    <link rel="stylesheet" href="/staff/layout/css/font_eolqem241z66flxr.css" media="all" />
    <script type="text/javascript" src="/staff/layout/js/jquery.min.js"></script>
    <style type="text/css">
        th,td{
            text-align: center ! important;
        }
    </style>
</head>
<body class="childrenBody">
<blockquote class="layui-elem-quote news_search">
    <form class="layui-form" id="form" action="/admin/setmeal/index" method="get">
      <div class="layui-input-inline" style="margin-top: 5px;margin-right: 15px;">
            <label class="layui-form-label" style="padding: 0;width: 66px;height: 38px;background:#1AA094;text-align: center;line-height: 38px;border-radius: 2px;">公告名称</label>
            <input type="text" name="model" value="" placeholder="" class="layui-input search_input" style="width: 11em">
      </div>
      <div class="layui-inline">
        <a class="layui-btn search_btn" style="margin-top: 5px;" id="affiche">查询</a>
         <a class="layui-btn linksAdd_btn" style="background-color:#161917;margin-top: 5px;">添加</a>
      </div>
    </form>
</blockquote>

<div class="layui-form links_list">
    <table class="layui-table">
        {{ csrf_field() }}
        <thead>
        <tr>
            <th>公告名称</th>
            <th>日期</th>
            <th>来源</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody class="news_content">
        @if(!empty($data))
            @foreach($data as $v)
                <tr id="affiche_{{$v['id']}}">
                    <td class="account" >{{$v['title']}}</td>
                    <td>{{$v['time']}}</td>
                    <td style="color: #33a41d">{{$v['staff']}}</td>
                    <td>
                        <a class="layui-btn layui-btn-mini read" affiche="{{$v['id']}}"><i class="iconfont icon-wenben "></i> 查看</a>
                      <a class="layui-btn layui-btn-danger layui-btn-mini links_del" data-id="1" onclick="delAffiche({{$v['id']}})"><i class="layui-icon"></i> 删除</a>
                    </td>
                </tr>
            @endforeach
        @endif

</tbody>
</table>
</div>
</body>
<script type="text/javascript" src="/pc/layout/js/jquery.min.js"></script>
<script type="text/javascript" src="/pc/layui/layui.js"></script>
<script type="text/javascript">
    layui.config({
        base : "js/"
    }).use(['form','layer','jquery','laypage','element','laydate'],function(){
        var laydate = layui.laydate;
        var element = layui.element();
        var form = layui.form(),
            layer = parent.layer === undefined ? layui.layer : parent.layer,
            laypage = layui.laypage,
            $ = layui.jquery;

            // 查看
            $("body").on("click",".read",function(){  
            var _this = $(this);
            var id = _this.attr('affiche');
            layui.layer.open({
            title : "查看公告",
            type: 2, 
            content: '/admin/affiche/read?id='+id, 
            area: ['50em', '50em']
                });      
            })
             // 添加
            $(".linksAdd_btn").click(function(){
            layui.layer.open({
            title : "添加公告",
            type : 2,
            content : '/admin/affiche/create',
             area: ['50em', '50em'],
               })
            })
     })   


        $('#affiche').click(function () {
                $('#form').submit();
            })


       function delAffiche(id){  //删除
        layer.confirm('确定删除此信息？',{icon:3, title:'提示信息'},function(index){
            $.ajax({
                url:'/admin/affiche/delete',
                type:'post',
                async:false,
                data:{
                    "_token": $("input[name=_token]").val(),
                    'id':id
                },
                dataType:'json',
                success:function (data) {
                    if(data.status == 1){
                        $('#affiche_'+id).remove();
                        layer.msg('删除成功！',{time:800});
                         // parent.location.reload();
                         layer.close(index);
                    }
                }
            })
            layer.close(index);
        });
    }
</script>
</html>